package com.violet.auth.client.properties;

import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * @Author: wqf
 * @Date: 2023/06/30
 * @Description:
 */
@Getter
@Setter
public class PermitProperties {

    private static final String[] DEFAULT_LIST = {
            "/swagger-ui.html",
            "/swagger-ui/**",
            "/doc.html/**",
            "/v3/api-docs",
            "/druid/**",
            "/oauth/**",
            "/actuator/**",
            "/v2/api-docs",
            "/swagger/api-docs",
            "/swagger-resources/**",
            "/webjars/**"};


    /**
     * 网关请求白名单
     */
    private String[] httpUrls = {};

    public String[] getUrls() {
        if (httpUrls == null || httpUrls.length == 0) {
            return DEFAULT_LIST;
        }
        List<String> list = new ArrayList<>(Arrays.asList(DEFAULT_LIST));
        Collections.addAll(list, httpUrls);
        return list.toArray(new String[0]);
    }
}
